
public class SurveyDriver {

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		/*
		 * 1. Creating a new survey
		 */
		System.out.println("1. Creating a new survey named - Survey #1");
		
		SurveyNode survey = new SurveyNode();
		survey.setName("Survey #1");
		
		/*
		 * 2. Creating questions and adding them to a survey
		 * A question gets created with its "Choice" and its Answer(s).
		 * It is not completely clear to me what is the relationship between 
		 * the Question, Choice and Answer classes. 
		 * It looks like the Choice class is used for multiple purposes, this is
		 * - 	holding the type of the answer choice (e.g. true-false, multiple 
		 * 		choice, or essay)
		 * -	maintaining the answer in case of a single answer, and multiple 
		 * 		answers in the case of a multiple choice question.
		 * A few problems with this:
		 * 2.1 class Choice has weak cohesion because it serves multiple purposes
		 * 2.2 The idea of a class having the attribute "type" in it 
		 * (ChoiceType in the Choice class) is counter the object oriented paradigm.
		 * Objects of  different types behave differently and should be of different class, 
		 * rather than one class with the "type" attribute. These 3 classes 
		 * (Question, Choice and Answer) are tightly coupled because they are all 
		 * used for all types of questions and answers.
		 * 2.3 Having a type be a string, means that user code will have a big 
		 * switch block going over all types rather than that being hidden behind 
		 * the Choice class interface
		 * 2.4 It is not clear how this design handles matching questions. 
		 * 2.5 Generally the Question, Choice and Answer classes have no functionality
		 * in them! They have data members, accessors and mutators. They are no different than 
		 * structs in the C language!
		 */
		System.out.println("2. Creating Question, Choice, and Answer objects for the survey\n\n");
		
		
		System.out.println("Creating question Q1");
		Question q1 = new Question();
		q1.setName(new String("Q1"));
		q1.setQuestion(new String("Is 1 + 1 = 2 ?"));
		q1.setPoint(10);
		
		System.out.println("Creating Choice C1, type is true-false");
		// it is not clear to me what purpose does the "name" field in choice fulfills
		Choice c1 = new Choice();
		c1.setChoiceType(new String("true-false"));
		c1.setName("C1");
		
		System.out.println("Creating answer A1\n");
		Answer a1 = new Answer();
		a1.setAnswer(new String("true"));
		a1.setName(new String("A1"));
		
		q1.itsChoice.add(c1);
		q1.itsAnswers.add(a1);
		
		/*
		 * Create a multiple choice question, which is self gradable
		 */
		
		System.out.println("Creating question Q2");
		Question q2 = new Question();
		q2.setName(new String("Q2"));
		q2.setQuestion(new String("Select one of the following"));
		q2.setPoint(15);
		
		System.out.println("Creating Choice C2, type is multiple-selection");
		// it is not clear to me what purpose does the "name" field in choice fulfills
		Choice c2 = new Choice();
		c2.setChoiceType(new String("multiple-selection"));
		c2.setName("C2");
		
		System.out.println("Creating answer A2_1");
		Answer a2_1 = new Answer();
		a2_1.setAnswer(new String("1 + 1 = 2"));
		a2_1.setName(new String("A2_1"));
		
		System.out.println("Creating answer A2_2");
		Answer a2_2 = new Answer();
		a2_2.setAnswer(new String("1 + 1 = 5"));
		a2_2.setName("A2_2");
		
		System.out.println("Creating answer A2_3\n");
		Answer a2_3 = new Answer();
		a2_3.setAnswer(new String("1 + 1 = 0"));
		a2_3.setName(new String("A2_3"));
		
		// I assume that the association between Question and Answer is for the 
		// pre-answered answer
		
		System.out.println("Creating answer for self grading Q2\n");
		Answer a2_result = new Answer();
		a2_result.setAnswer(new String("1 + 1 = 2"));
		a2_result.setName(new String("A2_result"));

		q2.itsChoice.add(c2);
		q2.itsAnswers.add(a2_1);
		q2.itsAnswers.add(a2_2);
		q2.itsAnswers.add(a2_3);
		q2.itsAnswers.add(a2_result);
		
		
		
		/*
		 * 3. Adding questions and Answers to the survey
		 * I do not know what the interface Survey.addAnswer() is supposed to do,
		 * because there is no class implementing Survey that has answers, or does something 
		 * with them
		 */

		System.out.println("3. Adding Q1 and Q2 to the survey");
		survey.addQuestion(q1);
		survey.addQuestion(q2);
		System.out.println("\n\n");
		/*
		 * 4. Taking a survey
		 * A survey should be an object that knows how to execute some one taking it.
		 * I did not understand what is the role of the argument 'survey'
		 * in the interface Survey.takeSurvey(Survey survey) ....
		 * Also the interface methods Survey.addSurvey(Survey) and Survey.removeSurvey(Survey)
		 * do not make sense, since there is no mentioning in the design about nested surveys ...
		 * So I just called Survey with null ...
		 * 
		 */
		
		System.out.println("4. Calling survey.takeSurvey():\n");
		survey.takeSurvey(null);
		
		// there is no mentioning in the design how self-gradable questions are graded
		
		/*
		 * 5. Editing a survey
		 */
		System.out.println("\n5. Editing the Survey\n");
		
		// not clear what add\remove grade point do!
		// (or what is the role of class GradePoint) 
		survey.addGradePoint(10);
		survey.removeGradePoint(new GradePoint());
		System.out.println("");
		
		// and what is add\remove survey to a survey???
		SurveyNode sn = new SurveyNode();
		survey.addSurvey(sn);
		survey.removeSurvey(sn);
		// and what is this? help!
		survey.modifiedSurvey(sn);
		
		// remove a question from a survey
		// there is no interface for removing a question from a survey
		// there is also no interface for accessing a question for editing ...
		 
		/*
		 * 6. Grade a survey
		 * Why does "grade" grade one question? "grade" should operate on all questions in
		 * the survey ...
		 */
		System.out.println("");
		System.out.println("6. Grading the survey");
		
		survey.gradeQuestion(q1);
		survey.gradeQuestion(q2);
		
		System.out.println("\n\ndone, goodbye");
	}

}
